package com.bkgy.modular.configureRules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.configureRules.dto.LTKHDegreeGrading2130Dto;
import com.bkgy.modular.configureRules.entity.LTKHDegreeGrading2130;
import com.bkgy.modular.configureRules.mapper.LTKHDegreeGrading2130Mapper;
import com.bkgy.modular.configureRules.service.LTKHDegreeGrading2130Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @ClassName LTKHDegreeGrading2130ServiceImpl
 * @date 2023/4/19 10:43
 */
@Service
public class LTKHDegreeGrading2130ServiceImpl extends ServiceImpl<LTKHDegreeGrading2130Mapper, LTKHDegreeGrading2130> implements LTKHDegreeGrading2130Service {

    @Resource
    private LTKHDegreeGrading2130Mapper ltkhDegreeGrading2130Mapper;

    @Override
    public ResultData queryLTKHDegreeGrading2130() {
        List<LTKHDegreeGrading2130> list = ltkhDegreeGrading2130Mapper.selectList(null);
        return ResultData.ResultDataFaultSelf("操作成功",list);
    }

    @Override
    public ResultData updateLTKHDegreeGrading2130(LTKHDegreeGrading2130Dto dto) {
        Double classid = dto.getClassid();
        if (classid == null) {
            return ResultData.ResultDataFaultSelf("参数有误,请检查参数",-1);
        }
        String yp_class = dto.getYp_class();
        Double wid_class = dto.getWid_class();
        Double thk_class = dto.getThk_class();
        Double strip_paopian_limit = dto.getStrip_paopian_limit();
        LambdaQueryWrapper<LTKHDegreeGrading2130> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(LTKHDegreeGrading2130::getClassid,classid);

        LTKHDegreeGrading2130 ltkhDegreeGrading2130 = ltkhDegreeGrading2130Mapper.selectOne(queryWrapper);
        ltkhDegreeGrading2130.setWid_class(wid_class);
        ltkhDegreeGrading2130.setYp_class(yp_class);
        ltkhDegreeGrading2130.setStrip_paopian_limit(strip_paopian_limit);
        ltkhDegreeGrading2130.setThk_class(thk_class);
        int flag = ltkhDegreeGrading2130Mapper.update(ltkhDegreeGrading2130, queryWrapper);
        if (flag == 1) {
            return ResultData.ResultDataFaultSelf("操作成功",1);
        }
        return ResultData.ResultDataFaultSelf("操作失败",-1);
    }
}
